package cn.edu.cxcyzx.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.edu.cxcyzx.entity.MiddleCheck;
import cn.edu.cxcyzx.service.MiddleCheckService;
import cn.edu.cxcyzx.supervisor.DaoFit;
import cn.edu.cxcyzx.supervisor.ResultDo;

@Service("MiddleCheckService")
public class MiddleCheckServiceImpl implements MiddleCheckService {
	
	@Resource
	public DaoFit daoFit;
	
	@Override
	public void insertOne(MiddleCheck middleCheck) {
		// TODO Auto-generated method stub
		if(middleCheck!=null){
			middleCheck.setCheck_status(0);
			this.daoFit.getMiddleCheckDao().insertOne(middleCheck);
		}
	}

	@Override
	public ResultDo<MiddleCheck> getMiddleCheck(int projectId) {
		// TODO Auto-generated method stub
		ResultDo<MiddleCheck> resultDo=new ResultDo<>();
		MiddleCheck middleCheck=daoFit.getMiddleCheckDao().getMiddleCheck(projectId);
		if(middleCheck!=null){
			resultDo.setSuccess(true);
			middleCheck.setCheck_require(middleCheck.getCheck_require().trim());
			resultDo.setResult(middleCheck);
		}else{
			resultDo.setSuccess(false);
		}
		return resultDo;
	}

	@Override
	public void update_middleCheck(int projectId, int check_status) {
		// TODO Auto-generated method stub
		daoFit.getMiddleCheckDao().update_middleCheck(projectId, check_status);
	}

}
